﻿<!DOCTYPE html
  PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=EDGE;IE=11;IE=8,chrome=1" />
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>材料送检提醒查询</title>
    <link href="/InSiteWebApplication/Content/Easyui/themes/metro/easyui.css" rel="stylesheet" />
    <link href="/InSiteWebApplication/Content/Easyui/custom-easyui.css" rel="stylesheet" />
    <link href="/InSiteWebApplication/Content/Easyui/themes/icon.css" rel="stylesheet" />
    <link rel="stylesheet" href="/InSiteWebApplication/Content/webuploader/webuploader.css" />
    <style>
        .easyui-linkbutton{margin-left:20px;}
        table tr td{padding:0px 5px}
        .webuploader-pick{padding:0px 0px;border-radius:0px}
        .filebox{height: 30px;}
        #fm .l-btn-text{margin-top:3px}
    </style>
</head>
<body>
    <div class="panelSection">    
        <div class="easyui-panel " title="查询区域" style="padding:3px;width:100%" data-options="closable:false,collapsible:true,minimizable:false,maximizable:false"> 
           <form id="searchForm" method="post">
	    	<table>
	    		<tr class="divLabel">
                    <td>材料批次号:</td>
                    <td>材料编码:</td>
                    <td>材料描述:</td>
	    		</tr>
	    		<tr>
	    			<td><input  name="Charg" class="easyui-textbox" style="width: 120px; height: 22px" /></td>
	    			<td><input  name="Name" class="easyui-textbox" style="width: 120px; height: 22px" /></td>
                    <td><input  name="Description" class="easyui-textbox" style="width: 120px; height: 22px" /></td>
                    <td> <span style="margin-right: 5px;">
                            <input type="radio"  name="Status" value="0" checked="true" id="Status"/><label for="Status">只显示异常</label></span>
                            <input type="radio"  name="Status" value="1"  id="Status1"/><label for="Status1">显示全部</label>
                     </td>
                    <td><a href="javascript:void(0)" class="easyui-linkbutton" onclick="page.searchData()">查询</a></td>
	    			<td><a href="javascript:void(0)" class="easyui-linkbutton" onclick="page.searchReset()">重置</a></td>
	    		</tr>
	    	</table>
	    </form>
        </div> 
    </div>

    <div class="panelSection">    
      <div class="easyui-panel " title="材料送检提醒统计" style="padding:3px;width:100%" data-options="closable:false,collapsible:true,minimizable:false,maximizable:false"> 
        <table id="NotProductMaterialGiveCheckRemind" style="height:440px;width:100%" data-options="rownumbers:true"></table>
        <div id="pp" style="float: right" class="easyui-pagination" data-options="   
                 layout:['first','prev','next','last','manual','info'],              
                    total: 0,
                    showPageList: false,
                    showPageInfo: false,
                    showRefresh: false,
                    afterPageText:'共&nbsp{pages}&nbsp页',
                     buttons:[{
                            iconCls:'',
                            text:'Go',
                            id:'pageGo'
                    }]
                ">
                    </div>
        <div style="margin-top:7px;">
            <span class="divLabel">送检周期:</span><input class="easyui-numberbox" style="width: 120px; height: 22px" id="SendCheckCycle"/>
            <span class="divLabel">有效期:</span><input class="easyui-datebox" style="width: 120px; height: 22px" id="vlDate"/>
        </div>
        </div>
      </div>

      <div class="panelSection">    
      <div class="easyui-panel " title="按钮区域" style="padding:3px;width:100%">
            <a href="javascript:void(0)" class="easyui-linkbutton" onclick="page.setSendCheckCycle()">设定送检提请周期</a>
            <a href="javascript:void(0)" class="easyui-linkbutton" onclick="page.updateVlDate()">更新有效期</a>
            <!--<a href="javascript:void(0)" class="easyui-linkbutton" style="height:auto" id="importSendCheckCycleVlDate">送检周期/有效期导入</a>
            <input id="txtExcelFileId" type="hidden" />-->
            <form id="fm" method="post" enctype="multipart/form-data" style="display:inline-block;margin-left:20px;">
             <input class="easyui-filebox" id="fileUpload" name="fileUpload" style="width:140px;height: 24px;line-height: 24px;" data-options="buttonText:'送检周期/有效期导入',onChange:function(){page.easyuiUpload(this);}"/>
             </form>
             <!--<a href="javascript:void(0)" class="easyui-linkbutton" style="height:auto" onclick="$('#filebox_file_id_1').click();">送检周期/有效期导入</a>-->
      </div>
    </div>

     <!--信息提示区域-->
    <div id="statusMessage" style="font-size: 14px; height: 40px"></div>
</body>
</html>
<script src="/InSiteWebApplication/Scripts/json2.js" type="text/javascript"></script>
<script src="/InSiteWebApplication/Content/Easyui/jquery.min.js" type="text/javascript"></script>
<script src="/InSiteWebApplication/Content/Easyui/jquery.easyui.min.js" type="text/javascript"></script>
<script src="/InSiteWebApplication/Content/Easyui/easyui-lang-zh_CN.js" type="text/javascript"></script>
<script src="/InSiteWebApplication/Scripts/CustomPageJs/CustomCommon.js" type="text/javascript"></script>
<script type="text/javascript" src="/InSiteWebApplication/Content/webuploader/webuploader.js"></script>
<script type="text/javascript">
    //创建人：longb
    //日期：2022-07-22
    //描述：材料送检提醒
    var page = {
        pagetotal: 0,
        pageSize: 20,
        pageNumber: 1,
        rootPath: getRootPath(), //网站根路径
        ajaxUrl: getRootPath() + "/Ashx/ZsHandler/ZSReciveMaterialConfirmHandler.ashx",
        //初始化页面
        init: function () {
            page.bind();
            customizedEasyuiPagination('pp'); //定制化分页
            page.InitUploader();
        },
        //页面事件绑定
        bind: function () {
            $('#NotProductMaterialGiveCheckRemind').datagrid({
                checkOnSelect: true,
                selectOnCheck: false,
                singleSelect: true,
                rownumbers: true,
                onLoadSuccess: function (data) {
                    $('#pp').pagination('refresh', {	// 改变选项，并刷新分页栏信息
                        total: page.pagetotal,
                        pageSize: page.pageSize,
                        pageNumber: page.pageNumber
                    });
                    customizedEasyuiPagination('pp'); //定制化分页
                },
                columns: [[
                 { field: 'ck', title: '选择', checkbox: true },
                 { field: 'CHARG', title: '材料批次号', width: 140 },
                 { field: 'MATNR', title: '材料编码', width: 140 },
		         { field: 'MAKTX', title: '材料描述', width: 140 },
                 { field: 'SPECIFICATION', title: '型号规格', width: 90 },
                 { field: 'MTART', title: '材料类型', width: 100 },
                 { field: 'VLDAT', title: '有效期', width: 90 },
		         { field: 'ISSENDCHECK', title: '是否需要送检', width: 90, align: 'center' },
                 { field: 'SENDCHECKCYCLE', title: '送检提请周期（天）', width: 150, align: 'center' },
                 { field: 'SENDSTATUS', title: '送检提醒', width: 90, styler: function (value, row, index) {
                     if (value == "按期送检") { return 'color:orange;'; }
                     else if (value == "逾期未检") { return 'color:red;'; }
                     else { return 'color:green;'; }
                 }
                 }
                ]]
            });
            //分页事件
            $('#pp').pagination({
                onSelectPage: function (pageNumber, pageSize) {
                    customizedEasyuiPagination('pp'); //定制化分页
                    page.pageSize = pageSize; page.pageNumber = pageNumber;
                    page.GetNotProductMaterialGiveCheckRemind();
                }
            });
            //绑定分页go按钮
            $('#pageGo').on("click", function () {
                var pageNumber = $(this).parents('tr').find('.pagination-num').val();
                page.pageNumber = pageNumber;
                page.GetNotProductMaterialGiveCheckRemind();
            });
            //清除按钮
            $('#btnReset').on("click", function () {
                page.reset(true, true);
                page.pageNumber = 1; page.pagetotal = 0
                $('#pp').pagination('refresh', {
                    total: page.pagetotal,
                    pageSize: page.pageSize,
                    pageNumber: page.pageNumber
                });
            });
        },
        //查询
        searchData: function () {
            clearMessage();
            page.pageNumber = 1;
            page.GetNotProductMaterialGiveCheckRemind();
        },
        //查询重置
        searchReset: function () {
            $('#searchForm').form('clear');
            $('#Status').prop("checked", true);
            clearMessage();
        },
        //查询任务单信息
        GetNotProductMaterialGiveCheckRemind: function () {
            var frdata = $('#searchForm').serializeArray();
            var data = {};
            $.each(frdata, function () {
                data[this.name] = this.value
            });
            var param = {
                action: "GetNotProductMaterialGiveCheckRemind",
                pageSize: page.pageSize,
                pageNumber: page.pageNumber,
                data: JSON.stringify([data])
            };
            page.post(param, function (res) {
                if (res.Result) {
                    page.pagetotal = res.RowCount;
                    $('#NotProductMaterialGiveCheckRemind').datagrid('loadData', res.DBTable);
                }
            });
        },
        //设定送检提请周期
        setSendCheckCycle: function () {
            var rows = $('#NotProductMaterialGiveCheckRemind').datagrid('getChecked');
            var sendCheckCycle = $('#SendCheckCycle').numberbox('getValue');
            if (rows.lenght == 0) { displayMessage('请勾选至少一条记录再进行操作', false); return; }
            if (sendCheckCycle == "") { displayMessage('请输入送检周期再进行操作', false); return; }
            page.post({ action: 'UpdateNotProductMaterialData', data: JSON.stringify(rows), sendCheckCycle: sendCheckCycle, vlDate: '' }, function (res) {
                if (res.Result) { page.GetNotProductMaterialGiveCheckRemind(); }
                displayMessage(res.Message, res.Result);
            });
        },
        //更新有效期
        updateVlDate: function () {
            var rows = $('#NotProductMaterialGiveCheckRemind').datagrid('getChecked');
            var vlDate = $('#vlDate').datebox('getValue');
            if (rows.lenght == 0) { displayMessage('请勾选至少一条记录再进行操作', false); return; }
            if (vlDate == "") { displayMessage('请输入有效期再进行操作', false); return; }
            page.post({ action: 'UpdateNotProductMaterialData', data: JSON.stringify(rows), sendCheckCycle: '', vlDate: vlDate }, function (res) {
                if (res.Result) { page.GetNotProductMaterialGiveCheckRemind(); }
                displayMessage(res.Message, res.Result);
            });
        },
        //导入组件初始化
        InitUploader: function () {
            var uploader = WebUploader.create({
                // swf文件路径
                swf: page.rootPath + "/Content/webuploader/Uploader.swf",
                // 文件接收服务端。
                server: page.ajaxUrl,
                // 内部根据当前运行是创建，可能是input元素，也可能是flash.
                pick: '#importSendCheckCycleVlDate',
                // 不压缩image, 默认如果是jpeg，文件上传前会压缩一把再上传！
                resize: false,
                formData: {
                    action: "ImportSendCheckCycleVlDate"
                },
                accept: {
                    title: 'Excel',
                    extensions: 'xlsx,xls',
                    mimeTypes: 'excel/*'
                }
            });
            // 当有文件被添加进队列的时候，每次只传一个文件
            uploader.on('fileQueued', function (file) {
                if ($('#txtExcelFileId').val() != "") {
                    var f = uploader.getFile($('#txtExcelFileId').val()); //找到上一次队列中的文件
                    uploader.removeFile(f, true); //删除掉上一次队列中的文件
                }
                $('#txtExcelFileId').val(file.id);
                displayMessage("", true);
                uploader.upload();
                $.messager.progress({ text: '', msg: '处理中...' });
            });
            //上传成功
            uploader.on('uploadSuccess', function (file, response) {
                var result = response;
                displayMessage(result.Message, result.Result);
                $.messager.progress('close');
                var f = uploader.getFile(file.id); //找到上传的文件
                uploader.removeFile(f, true); //将其从队列中的删掉
                $('#txtExcelFileId').val("");
                page.GetNotProductMaterialGiveCheckRemind();
            });
            //上传失败
            uploader.on('uploadError', function (file) {
                displayMessage("上传失败", false);
                var f = uploader.getFile(file.id); //找到上传的文件
                uploader.removeFile(f, true); //将其从队列中的删掉
                $.messager.progress('close');
                $('#txtExcelFileId').val("");

            });
        },

        easyuiUpload: function (obj) {
            if ($('#fileUpload').filebox('getValue') != "") {
                clearMessage();
                $('#fm').form('submit', {
                    url: page.ajaxUrl + "?action=ImportSendCheckCycleVlDate",
                    onSubmit: function () {
                        return $(this).form('validate');
                    },
                    success: function (result) {
                        $('#fileUpload').filebox('clear');
                        var res = JSON.parse(result); 
                        displayMessage(res.Message, res.Result);
                    }
                });
            }
        },
        //清除方法，重要！！！
        reset: function (iscondition, isresult) {
            clearMessage();
        },
        //post数据
        post: function (param, callback) {
            $.ajax({
                type: "Post",
                url: page.ajaxUrl,
                data: param,
                cashe: false,
                async: true,
                dataType: "json",
                beforeSend: function () {
                    $.messager.progress({ text: '', msg: '处理中...' });
                },
                success: function (data) {
                    $.messager.progress('close');
                    callback(data);
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    $.messager.progress('close');
                    displayMessage(XMLHttpRequest.responseText, false);
                }
            });
        }
    }
    $(function () {
        page.init();
    });
</script>
